// pages/estatetheme/estatetheme.js
let app = getApp();
Page({
  data: {
    menuList: [{
      name: "概况"
    }, {
      name: "新房"
    }, {
      name: "二手房"
    }],
    tabScroll: 0,
    currentTab: 0,
    height: 600,

    swiperList: [{
      id: 0,
      type: 'image',
      number: '123',
      name: 'ym',
      url: 'https://s1.ax1x.com/2020/05/08/Yn395F.png'
    }, {
      id: 1,
      type: 'image',
      number: '123',
      name: 'ymm',
      url: 'https://s1.ax1x.com/2020/05/08/Yn395F.png',
    }, {
      id: 2,
      type: 'image',
      number: '123',
      name: 'ymmmm',
      url: 'https://s1.ax1x.com/2020/05/08/Yn395F.png',
    }, {
      id: 3,
      type: 'image',
      number: '123',
      name: 'ymm',
      url: 'https://s1.ax1x.com/2020/05/08/Yn395F.png',
    }]
  },
  onLoad: function () {
    let that = this;
    that.setData({
      height: app.globalData.screenHeight - 50,
      tabTop: app.globalData.tabTop,
      tabbarH: app.globalData.tabbarH,
      tabBarHeight: app.globalData.tabBarHeight,
      screenHeight: app.globalData.screenHeight,
      clientHeight: app.globalData.clientHeight,
      clientHeight2: app.globalData.clientHeight2
    })
  },
  onReady: function () {

  },
  //点击tab menu
  clickMenu: function (e) {
    let that = this;
    var current = e.currentTarget.dataset.current; //获取当前tab的index
    let height = app.globalData.screenHeight - 50
    // 导航tab共5个，获取一个的宽度
    var tabWidth = that.data.windowWidth / 5;
    that.setData({
      tabScroll: (current - 2) * tabWidth//使点击的tab始终在居中位置
    })
    if (that.data.currentTab == current) {
      return false
    } else {
      height = current == 1 || current == 2 ? height - 40 : height
      that.setData({
        currentTab: current,
        height: height
      })
    }
  },
  //活动menu 内容
  changeContent: function (e) {
    let that = this;
    var current = e.detail.current // 获取当前内容所在index,文档有
    var tabWidth = that.data.windowWidth / 5
    let height = app.globalData.screenHeight - 50
    height = current == 1 || current == 2 ? height - 40 : height
    that.setData({
      currentTab: current,
      tabScroll: (current - 2) * tabWidth,
      height: height
    })
  }
})